package serializable;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/5/15
 */
public class SerializableDemo1 {
    public static void main(String[] args) {
        try(ObjectOutputStream oos = new ObjectOutputStream(
                new FileOutputStream("user.txt"))){

            User1 user1= new User1("xiaohua",19,"男","123","蚌埠");
//            User2 user2 = new User2("xiaohua",19,"男","123","蚌埠");
//            User3 user3 = new User3("xiaohua",19,"男","123","蚌埠");
            user1.setCount(100);
            oos.writeObject(user1);
            oos.flush();
            System.out.println(user1);
            System.out.println("写出成功！");
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
